import request from '@/utils/request';
// @ts-ignore
import {MALL_PATH_WEB_PREFIX} from '@/types/store/prefix.d.ts';

/**
 * 获取商品分类列表
 *
 * @param queryParams
 */
export function listCategories(queryParams: object) {
  return request({
    url: MALL_PATH_WEB_PREFIX + '/category/tree',
    method: 'get',
    params: queryParams,
  });
}

/**
 * 获取商品分类级联器树形列表
 *
 * @param queryParams
 */
export function listCascadeCategories(queryParams?: object) {
  return request({
    url: MALL_PATH_WEB_PREFIX + '/category/option',
    method: 'get',
    params: queryParams,
  });
}

/**
 * 添加商品分类
 *
 * @param data
 */
export function addCategory(data: object) {
  return request({
    url: MALL_PATH_WEB_PREFIX + '/category',
    method: 'post',
    data: data,
  });
}

/**
 * 修改商品分类
 *
 * @param id
 * @param data
 */
export function updateCategory(id: number, data: object) {
  return request({
    url: MALL_PATH_WEB_PREFIX + '/category/' + id,
    method: 'put',
    data: data,
  });
}

/**
 * 删除商品分类
 *
 * @param ids
 */
export function deleteCategories(ids: string) {
  return request({
    url: MALL_PATH_WEB_PREFIX + '/category/list',
    method: 'delete',
    params: {ids: ids},
  });
}

